package com.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class HttpSessionInterceptor implements Interceptor {

	public void destroy() {
		// TODO Auto-generated method stub

	}

	public void init() {
		// TODO Auto-generated method stub

	}

	public String intercept(ActionInvocation invok) {
		String stuffid = "";
		String r = "";
		try {
			HttpServletRequest req = ServletActionContext.getRequest();
			stuffid = (String) req.getSession().getAttribute("stuffid");
		} catch (Exception e) {
			e.printStackTrace();
			return "pleaselogin";
		}

		if (stuffid != "" && stuffid != null) {
			try {
				r = invok.invoke();	
			} catch (Exception e) {
				e.printStackTrace();
			}
			return r;
		} else {
			return "pleaselogin";
		}

	}

}
